<div class="table-content">
	<div class="layui-form-bar border-t border-x">
		<button class="layui-btn layui-btn-sm layui-btn-normal add-new">+ 新建需求</button>
	</div>
	<table class="layui-hide" id="requirements" lay-filter="test"></table>
</div>

<script type="text/html" id="barDemo">
<div class="layui-btn-group"><span class="layui-btn layui-btn-normal layui-btn-xs" lay-event="view">详细</span></div>
</script>

<script>
function pageInit() {
var project_id = {$id};
var table = layui.table,form = layui.form,gougu = layui.gougu;	
	layui.pageTable = table.render({
		elem: '#requirements',
		title: '需求列表',
		cellMinWidth:200,
		url: "/requirements/index/index",
		where:{'project_id':project_id},
		page: true, //开启分页
		limit: 20,
		cols:  [[
			{field:'id', title: '产品编号',width: 80, align:'center',fixed:'left',rowspan: 2,templet:function(d){		
				return 'R'+d.id;
			}}
			,{field:'flow_name',title: '状态',align:'center',width: 80,rowspan: 2,templet:function(d){
				var html = '<span class="layui-badge layui-bg-'+d.flow_status+'">'+d.flow_name+'</span>';
				return html;
			}}
			,{field:'title',title: '需求主题',rowspan: 2}
			,{field:'priority_name',title: '优先级',align:'center',width: 70,rowspan: 2,templet:function(d){
				var html = '<span class="layui-badge bg-priority-'+d.priority+'">'+d.priority_name+'</span>';			
				return html;
			}}
			,{field:'director_name',title: '负责人', align:'center',width: 90,rowspan: 2}
			,{field:'plan_time',title: '需求周期', align:'center',width: 180,rowspan: 2}				
			,{align: 'center', title: '关联任务', colspan: 3}
			,{align: 'center', title: '关联BUG', colspan: 3}

			,{fixed: 'right',title: '操作',align: 'center',width: 60,rowspan: 2,toolbar: '#barDemo',}
		], [
			{field:'tasks_a',align:'center', style:'color: #91CC75;', width:80,'title':'进行中'}
			,{field:'tasks_b',align:'center', style:'color: #FAC858;', width:80,'title':'已完成'}
			,{field:'tasks_c',align:'center', style:'color: #EE6666;', width:80,'title':'完成率'}
			,{field:'bugs_a',align:'center', style:'color: #91CC75;', width:80,'title':'进行中'}
			,{field:'bugs_b',align:'center', style:'color: #FAC858;', width:80,'title':'已完成'}
			,{field:'bugs_c',align:'center', style:'color: #EE6666;', width:80,'title':'修复率'}
		]]
	});
	
	$('.add-new').on('click',function(){
		gougu.open('/requirements/index/add?project_id='+project_id);
	});
	
	//监听行工具事件
	table.on('tool(test)', function(obj) {
		var data = obj.data;
		if (obj.event === 'view') {
			gougu.open('/requirements/index/view?id='+data.id);
			return;
		}
	});
}
</script>